<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    #app {
      width: 400px;
      height: 400px;
    }

    #app img {
      width: 100%;
      height: 300px;
    }
  </style>
</head>

<body>
  <div id='app'>
    <button v-show='flag1' @click="fn(1)">上一页</button>
    <!-- <img src="../images/1.jpg" alt=""> -->
    <img :src="list[yeshu]" alt="">
    <button v-show="flag2" @click="fn(2)">下一页</button>
  </div>
  <script src="../vue.js"></script>
  <script>
    const app = new Vue({
      el: '#app',
      data: {
        yeshu: 0,
        list: [
          '../images/1.jpg',
          '../images/2.jpg',
          '../images/3.jpg',
          '../images/4.jpg',
        ],
        flag1: false,
        flag2: true
      },
      methods: {
        fn(a) {
          if (a == 1) {// 上一页的按钮
            if (this.yeshu <= 0) {
              this.flag1 = false
            } else {
              this.flag2 = true
              this.yeshu--;
              if (this.yeshu <= 0) {
                this.flag1 = false
              }
            }
          } else {// 点击的是下一页
            if (this.yeshu >= this.list.length - 1) {
              this.flag2 = false;
            } else {
              this.yeshu++;
              if (this.yeshu >= this.list.length - 1) {
                this.flag2 = false;
              }
            }
            if (this.yeshu >= 1) {
              this.flag1 = true;
            }
          }
        }
      }
    })

  </script>
</body>

</html>